package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Setter@Getter
@JsonIgnoreProperties(value = {"handler","hibernateLazyInitializer","fieldHandler"})
public class StrategyCatalog extends BaseDomain{

    private String name;//名字

    private Strategy strategy;//大攻略

    private Integer sequence;//序号

    private Boolean state=true;//状态

    private List<StrategyDetail> strategyDetail=new ArrayList<>();

    public String getStateName() {
        if (state == true) {
            return "启用";
        } else if (state == false) {
            return "禁用";
        }
        return "";
    }

    public String getJsonString(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",getId());
        map.put("name",name);
        if (strategy!=null){
        map.put("strategyId",strategy.getId());
        }
        map.put("sequence",sequence);
        if (state != null) {
            map.put("state",state);
        }
        return JSONUtil.toJSONString(map);
    }
}